mac80211: add pending fix for wrong resource_size() usage for ath11k
authorChristian Marangi <[email protected]>
Mon, 8 Dec 2025 20:42:48 +0000 (21:42 +0100)
committerChristian Marangi <[email protected]>
Mon, 8 Dec 2025 20:44:26 +0000 (21:44 +0100)
Add pending fix for wrong resource_size() usage that cause firmware
crash on load on ath11k.

Refresh all affected patch by this.

Signed-off-by: Christian Marangi <[email protected]>
package/kernel/mac80211/patches/ath11k/101-wifi-ath11k-fix-wrong-usage-of-resource_size-causing.patch [new file with mode: 0644]
package/kernel/mac80211/patches/ath11k/201-wifi-ath11k-Support-setting-bdf-addr-and-caldb-addr-.patch

diff --git a/package/kernel/mac80211/patches/ath11k/101-wifi-ath11k-fix-wrong-usage-of-resource_size-causing.patch b/package/kernel/mac80211/patches/ath11k/101-wifi-ath11k-fix-wrong-usage-of-resource_size-causing.patch
new file mode 100644 (file)
index 0000000..ea3f64c
--- /dev/null
@@ -0,0 +1,69 @@
+From 88f17c87ddc9ee7467acdc322d383e5a443a55ab Mon Sep 17 00:00:00 2001
+From: Christian Marangi <[email protected]>
+Date: Mon, 8 Dec 2025 20:50:47 +0100
+Subject: [PATCH 1/2] wifi: ath11k: fix wrong usage of resource_size() causing
+ firmware panic
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+On converting to the of_reserved_mem_region_to_resource() helper with
+commit 900730dc4705 ("wifi: ath: Use
+of_reserved_mem_region_to_resource() for "memory-region"") a logic error
+was introduced in the ath11k_core_coldboot_cal_support() if condition.
+
+The original code checked for hremote_node presence and skipped
+ath11k_core_coldboot_cal_support() in the other switch case but now
+everything is driven entirely on the values of the resource struct.
+
+resource_size() (in this case) is wrongly assumed to return a size of
+zero if the passed resource struct is init to zero. This is not the case
+as a resource struct should be always init with correct values (or at
+best set the end value to -1 to signal it's not configured)
+(the return value of resource_size() for a resource struct with start
+and end set to zero is 1)
+
+On top of this, using resource_size() to check if a resource struct is
+initialized or not is generally wrong and other measure should be used
+instead.
+
+To better handle this, use the DEFINE_RES macro to initialize the
+resource struct and set the IORESOURCE_UNSET flag by default.
+
+Replace the resource_size() check with checking for the resource struct
+flags and check if it's IORESOURCE_UNSET.
+
+This change effectively restore the original logic and restore correct
+loading of the ath11k firmware (restoring correct functionality of
+Wi-Fi)
+
+Fixes: 900730dc4705 ("wifi: ath: Use of_reserved_mem_region_to_resource() for "memory-region"")
+Link: https://lore.kernel.org/all/[email protected]/T/#m990492684913c5a158ff0e5fc90697d8ad95351b
+Cc: Ilpo Järvinen <[email protected]>
+Signed-off-by: Christian Marangi <[email protected]>
+---
+ drivers/net/wireless/ath/ath11k/qmi.c | 4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+--- a/drivers/net/wireless/ath/ath11k/qmi.c
++++ b/drivers/net/wireless/ath/ath11k/qmi.c
+@@ -2039,8 +2039,8 @@ static int ath11k_qmi_alloc_target_mem_c
+ static int ath11k_qmi_assign_target_mem_chunk(struct ath11k_base *ab)
+ {
++      struct resource res = DEFINE_RES_NAMED(0, 0, NULL, IORESOURCE_UNSET);
+       struct device *dev = ab->dev;
+-      struct resource res = {};
+       u32 host_ddr_sz;
+       int i, idx, ret;
+@@ -2086,7 +2086,7 @@ static int ath11k_qmi_assign_target_mem_
+                       }
+                       if (ath11k_core_coldboot_cal_support(ab)) {
+-                              if (resource_size(&res)) {
++                              if (res.flags != IORESOURCE_UNSET) {
+                                       ab->qmi.target_mem[idx].paddr =
+                                                       res.start + host_ddr_sz;
+                                       ab->qmi.target_mem[idx].iaddr =
index f67aa4bb4f32a84ace6451f4c6b6be44e0c217e1..721b521887f162e9a1ba6e627f31420ab31296e2 100644 (file)
@@ -11,8 +11,8 @@ Signed-off-by: Ziyang Huang <[email protected]>
 --- a/drivers/net/wireless/ath/ath11k/qmi.c
 +++ b/drivers/net/wireless/ath/ath11k/qmi.c
 @@ -2042,6 +2042,7 @@ static int ath11k_qmi_assign_target_mem_
+       struct resource res = DEFINE_RES_NAMED(0, 0, NULL, IORESOURCE_UNSET);
        struct device *dev = ab->dev;
-       struct resource res = {};
        u32 host_ddr_sz;
 +      u32 addr;
        int i, idx, ret;